package com.pearadmin.pro.modules.mkt.rest;

import com.pearadmin.pro.modules.mkt.domain.MktActive;
import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import  com.pearadmin.pro.modules.mkt.domain.MktActive;
import  com.pearadmin.pro.modules.mkt.param.MktActiveRequest;
import  com.pearadmin.pro.modules.mkt.service.MktActiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 市场活动Controller
 *
 * @author chenJian
 * @date 2021-09-09
 */
@Api(tags = {"市场活动"})
@RestController
@RequestMapping(ControllerConstant.ADMIN+"mkt/mktActive")
public class MktActiveController extends BaseController
{
    @Resource
    private MktActiveService mktActiveService;

    /**
     * 查询市场活动列表
     *  @param request 查询参数
     *  @return {@link Result}
     */
    @GetMapping("/page")
    @Log(title = "市场活动列表")
    @ApiOperation(value = "市场活动列表")
    public Result<MktActive> list(MktActiveRequest mktActiveRequest)
    {
        return success(mktActiveService.page(mktActiveRequest));
    }


    /**
     * 新增保存市场活动
     * @param mktActive 查询参数
     * @return {@link Result}
     */
    @PostMapping("/save")
    @Log(title = "新增市场活动")
    @ApiOperation(value = "新增市场活动")
    public Result save(@RequestBody MktActive mktActive)
    {
        return auto(mktActiveService.actSaveOrUpdate(mktActive));
    }

    /**
     * 查询市场活动详情
     *
     * @param id 市场活动ID
     * @return 市场活动
     */
    @GetMapping("/selectById")
    @Log(title = "查询市场活动详情")
    @ApiOperation(value = "查询市场活动详情")
    public Result<MktActive> selectById(@RequestParam Long id)
    {
        return success(mktActiveService.selectMktActiveById(id));
    }



    /**
     * 修改保存市场活动
     * @param mktActive 查询参数
     * @return {@link Result}
     */
    @PutMapping("/update")
    @Log(title = "修改市场活动")
    @ApiOperation(value = "修改市场活动")
    public Result update(@RequestBody MktActive mktActive)
    {
        return auto(mktActiveService.actSaveOrUpdate(mktActive));
    }


    /**
     * 删除保存市场活动
     * @param id 查询参数
     * @return {@link Result}
     */
    @DeleteMapping("/remove")
    @Log(title = "删除市场活动")
    @ApiOperation(value = "删除市场活动")
    public Result remove(@RequestParam Long id)
    {
        return auto(mktActiveService.removeById(id));
    }



//
//    /**
//    * 批量删除市场活动
//    * @param ids 批量删除
//    * @return {@link Result}
//    */
//    @DeleteMapping("removeBatch")
//    @Log(title = "批量删除市场活动")
//    @ApiOperation(value = "批量删除市场活动")
//    public Result removeBatch(@RequestParam List<Long> ids){
//        return auto(mktActiveService.removeByIds(ids));
//    }

}
